package coreqto

import (
	"core/coreinfo"
	"core/corestruct"
	"core/coreutil"
	"reflect"
	"time"
)

type BasePageDtQto struct {
	BasePageQto
	Dtb string `json:"dtb"                              gorm:"column:dtb;comment:开始日期;"`
	Dte string `json:"dte"                              gorm:"column:dte;comment:截至日期;"`
}

/**
*获取开始日期
 */
func (p *BasePageDtQto) GetDtb() (*time.Time, error) {
	return coreutil.DateUtil.StrToDate(p.Dtb)
}

/**
*获取截至日期，是输入日期加1
 */
func (p *BasePageDtQto) GetDte() (*time.Time, error) {
	dt, err := coreutil.DateUtil.StrToDate(p.Dte)
	if err != nil {
		return nil, err
	}
	var r = dt.AddDate(0, 0, 1)
	return &r, err
}

/**
*注册类型
 */
func BasePageDtQtoInit() {
	var mcls = &BasePageDtQto{}
	var m = &corestruct.MyClass{
		Name:     "带分页和日期Dto",
		Ename:    "",
		FullName: "",
		Memo:     "",
		Fileds:   nil,
		PrjName:  coreinfo.PRJ_NAME,
		Type:     reflect.TypeOf(mcls),
	}
	coreutil.StructUtil.AddQto(m)
}
